"use client" import * as React from 'react' import { CircleCheck, Clock, Coins, Cpu, Hash, Replace, SlidersHorizontal } from 'lucide-react' import { Button } from '@open-mercato/ui/primitives/button' import { Avatar } from '@open-mercato/ui/primitives/avatar' import { StatusBadge } from '@open-mercato/ui/primitives/status-badge' import { SimpleTooltip } from '@open-mercato/ui/primitives/tooltip' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@open-mercato/ui/primitives/select' import { TagsInput } from '@open-mercato/ui/backend/inputs/TagsInput' import { flash } from '@open-mercato/ui/backend/FlashMessages' import { useT, useLocale } from '@open-mercato/shared/lib/i18n/context' import { formatCostMinor, formatNumber, type AgentDetailView, type AgentWindowMetricsView, } from '../../../../components/types' import { agentAvatarIcon, resolveAgentIcon } from '../../../../components/agentChips' import { useAgentTagSuggestions } from '../../../../components/useAgentTags' import { AGENT_ICON_NAMES } from '../../../../data/agentIcons' import { isAgentPreviewUiEnabled } from '../../../../lib/featureFlags' import { StatCell, PendingChip } from './workspacePrimitives' import { statusVariant, titleCase, type AgentMetrics, type Autonomy } from './workspaceShared' export const ICON_DEFAULT = '__default__' export type AgentHeaderCardProps = { agent: AgentDetailView metrics: AgentMetrics windowMetrics: AgentWindowMetricsView | null autonomy: Autonomy savingIcon: boolean savingTags: boolean onIconChange: (value: string) => void onTagsChange: (next: string[]) => void onConfigure: () => void } export function AgentHeaderCard({ agent, metrics, windowMetrics, autonomy, savingIcon, savingTags, onIconChange, onTagsChange, onConfigure, }: AgentHeaderCardProps) { const t = useT() const locale = useLocale() const tagSuggestions = useAgentTagSuggestions() const previewUi = isAgentPreviewUiEnabled() const overridePct = metrics.overrideRate == null ? null : Math.round(metrics.overrideRate * 100) const overrideGate = overridePct != null && overridePct > 30 const noData = t('agent_orchestrator.agents.list.pending.noData', 'No data') const codeOnly = t( 'agent_orchestrator.agentDetail.actions.codeOnly', 'This agent is defined by its definition file in the repository — its prompt, tools, model and outcome schema all come from that file, which is the single source of truth. Configuring or pausing an agent from the UI is planned for the next version of Agent Orchestrator; for now, edit the definition in code and redeploy.', ) return (

{agent.label || agent.id}

{t(`agent_orchestrator.agents.list.status.${metrics.status}`, titleCase(metrics.status))}

{agent.id}

{agent.description || agent.id}

{t('agent_orchestrator.agents.tags.label', 'Tags')}
{t('agent_orchestrator.agentDetail.icon.label', 'Icon')}
{previewUi ? ( <> {/* Pause had no handler beyond a toast, so it is DISABLED rather than clickable: a control that looks live and then explains it is not has already misled whoever pressed it. The span carries the tooltip because a disabled button receives no pointer events of its own. Configure stays enabled — it opens a real drawer showing the target UX, whose Save is disabled for the same reason. */} ) : null}
{formatNumber(metrics.runCount, locale) ?? '0'} {windowMetrics?.evalPassRate == null ? : {Math.round(windowMetrics.evalPassRate * 100)}%} {overridePct == null ? : {overridePct}%} {(() => { const value = formatCostMinor(windowMetrics?.avgCostMinor ?? null, windowMetrics?.currency ?? null) return value ? {value} : })()} {metrics.lastActive || '—'} {agent.defaultModel ?? t('agent_orchestrator.agentDetail.defaultValue')} {t(`agent_orchestrator.agents.list.autonomy.${autonomy}`, titleCase(autonomy))}
) }